﻿using System.Web.Mvc;
using Actya.Core.Infrastructure;
using Actya.Core.Widgets;
using Actya.Web.ViewModels;

namespace Actya.Web.Controllers
{
    public class WidgetController : Controller
    {
    	private readonly ICmsContext _cmsContext;
    	private readonly IWidgetService _widgetService;

    	public WidgetController(IWidgetService widgetService, ICmsContext cmsContext)
    	{
    		_widgetService = widgetService;
    		_cmsContext = cmsContext;
    	}

    	public ActionResult Display(string widgetId)
    	{
    		var widget = _widgetService.GetWidgetById(widgetId);
			widget.Initialize(_cmsContext);
    		return PartialView("_Widget", new WidgetViewModel { Widget = widget} );
    	}
    }
}
